const util = require("../../utils/util");

// index.js


Page({
  data: {
    orderNumber: '20230713001',
    orderAmount: '100.00',
    orderInfo: {
      id: '',
      name: '',
      mobile: '',
      address: '',
      total: 0,
      uid: 0,
      count: 0,
      pid: 0,
      single_cost: '',
    },
    respInfo:""
  },
  onLoad(options){
    this.data.orderInfo = wx.getStorageSync('订单信息')
    console.log(this.data.orderInfo)
    this.setData(this.data)
  },
  payOrder() {
    util.http('/order/create', this.data.orderInfo, resp=>{
      console.log("最终生成订单界面")
      this.data.respInfo = resp
    })
    // 模拟支付操作
    wx.showLoading({
      title: '正在支付...',
      mask: true
    });
    var that = this
    console.log("paying")
    setTimeout(function() {
      wx.hideLoading();
      wx.showToast({
        title: that.data.respInfo,
        icon: 'success',
        duration: 1000
      });
      setTimeout(function(){
        util.redirect('order')
      },1000);
    }, 1000);
    
  },
})